package com.yanqu.road.dao.impl.log;

import com.yanqu.road.dao.db.DbNameStrategy;
import com.yanqu.road.dao.db.DbParameter;
import com.yanqu.road.dao.impl.TempDao;
import com.yanqu.road.entity.monopolymarket.office.log.*;

import java.sql.Types;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description
 * @Author cwq
 * @Data 2021/9/22 21:30
 */
public class LogMonopolyMarketDaoImpl extends TempDao {

    public boolean addMonopolyMarketOfficeRobLogDataList(List<MonopolyMarketOfficeRobLogData> list) {
        boolean result = false;
        getDb().setConnName(DbNameStrategy.getCrossDb());
        String sql = "INSERT INTO t_c_monopolymarket_office_rob_log_data(groupId,posIndex,level,no,startTime,userId,decorationClass,title,prestige,type,isWin,robId,robDecorationClass,robTitle,robPrestige,logTime) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        List<Map<Integer, DbParameter>> mapList = new ArrayList<>();
        for (MonopolyMarketOfficeRobLogData data : list) {
            Map<Integer, DbParameter> para = new HashMap<>();
            int i = 1;
            para.put(i++, new DbParameter(Types.BIGINT, data.getGroupId()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getPosIndex()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getLevel()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getNo()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getStartTime()));
            para.put(i++, new DbParameter(Types.BIGINT, data.getUserId()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getDecorationClass()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getTitle()));
            para.put(i++, new DbParameter(Types.BIGINT, data.getPrestige()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getType()));
            para.put(i++, new DbParameter(Types.BOOLEAN, data.getIsWin()));
            para.put(i++, new DbParameter(Types.BIGINT, data.getRobId()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getRobDecorationClass()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getRobTitle()));
            para.put(i++, new DbParameter(Types.BIGINT, data.getRobPrestige()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getLogTime()));
            mapList.add(para);
        }
        if (getDb().executeBatchQuery(sql, mapList) > -1) {
            result = true;
        }
        return result;
    }

    public boolean addMonopolyMarketResGrabRobLogDataList(List<MonopolyMarketResGrabRobLogData> list) {
        boolean result = false;
        getDb().setConnName(DbNameStrategy.getCrossDb());
        String sql = "INSERT INTO t_c_monopolymarket_resgrab_rob_log_data(groupId,posIndex,side,level,type,remainTime,userId,objectStr,value,rewardNum,isWin,robId,robObjectStr,robValue,occupyStr,sitReward,logTime) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        List<Map<Integer, DbParameter>> mapList = new ArrayList<>();
        for (MonopolyMarketResGrabRobLogData data : list) {
            Map<Integer, DbParameter> para = new HashMap<>();
            int i = 1;
            para.put(i++, new DbParameter(Types.BIGINT, data.getGroupId()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getPosIndex()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getSide()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getLevel()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getType()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getRemainTime()));
            para.put(i++, new DbParameter(Types.BIGINT, data.getUserId()));
            para.put(i++, new DbParameter(Types.VARCHAR, data.getObjectStr()));
            para.put(i++, new DbParameter(Types.BIGINT, data.getValue()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getRewardNum()));
            para.put(i++, new DbParameter(Types.BOOLEAN, data.getIsWin()));
            para.put(i++, new DbParameter(Types.BIGINT, data.getRobId()));
            para.put(i++, new DbParameter(Types.VARCHAR, data.getRobObjectStr()));
            para.put(i++, new DbParameter(Types.BIGINT, data.getRobValue()));
            para.put(i++, new DbParameter(Types.VARCHAR, data.getOccupyStr()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getSitReward()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getLogTime()));
            mapList.add(para);
        }
        if (getDb().executeBatchQuery(sql, mapList) > -1) {
            result = true;
        }
        return result;
    }

    public boolean addMonopolyMarketUserPhysicalChangeLogDataList(List<MonopolyMarketUserPhysicalChangeLogData> list) {
        boolean result = false;
        getDb().setConnName(DbNameStrategy.getLogDb());
        String sql = "INSERT INTO t_l_monopolymarket_user_physical_log_data(userId,posIndex,level,no,type,oldValue,newValue,logTime) VALUES(?,?,?,?,?,?,?,?)";
        List<Map<Integer, DbParameter>> mapList = new ArrayList<>();
        for (MonopolyMarketUserPhysicalChangeLogData data : list) {
            Map<Integer, DbParameter> para = new HashMap<>();
            int i = 1;
            para.put(i++, new DbParameter(Types.BIGINT, data.getUserId()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getPosIndex()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getLevel()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getNo()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getType()));
            para.put(i++, new DbParameter(Types.BIGINT, data.getOldValue()));
            para.put(i++, new DbParameter(Types.BIGINT, data.getNewValue()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getLogTime()));
            mapList.add(para);
        }
        if (getDb().executeBatchQuery(sql, mapList) > -1) {
            result = true;
        }
        return result;
    }

    public boolean addMonopolyMarketFortressDispatchLogDataList(List<MonopolyMarketFortressDispatchLogData> list) {
        boolean result = false;
        getDb().setConnName(DbNameStrategy.getLogDb());
        String sql = "INSERT INTO t_l_monopolymarket_fortress_dispatch_log_data(groupId,weekId,fortressId,userId,unionId,patronsStr,dispatchEarn,unionDispatchEarn,logTime) VALUES(?,?,?,?,?,?,?,?,?)";
        List<Map<Integer, DbParameter>> mapList = new ArrayList<>();
        for (MonopolyMarketFortressDispatchLogData data : list) {
            Map<Integer, DbParameter> para = new HashMap<>();
            int i = 1;
            para.put(i++, new DbParameter(Types.BIGINT, data.getGroupId()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getWeekId()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getFortressId()));
            para.put(i++, new DbParameter(Types.BIGINT, data.getUserId()));
            para.put(i++, new DbParameter(Types.VARCHAR, data.getUnionId()));
            para.put(i++, new DbParameter(Types.VARCHAR, data.getPatronsStr()));
            para.put(i++, new DbParameter(Types.BIGINT, data.getDispatchEarn()));
            para.put(i++, new DbParameter(Types.BIGINT, data.getUnionDispatchEarn()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getLogTime()));
            mapList.add(para);
        }
        if (getDb().executeBatchQuery(sql, mapList) > -1) {
            result = true;
        }
        return result;
    }

    public boolean addMonopolyMarketFortressSettlementLogDataList(List<MonopolyMarketFortressSettlementLogData> list) {
        boolean result = false;
        getDb().setConnName(DbNameStrategy.getCrossDb());
        String sql = "INSERT INTO t_c_monopolymarket_fortress_dispatch_log_data(groupId,weekId,fortressId,unionId,unionDispatchEarn,rank,logTime) VALUES(?,?,?,?,?,?,?)";
        List<Map<Integer, DbParameter>> mapList = new ArrayList<>();
        for (MonopolyMarketFortressSettlementLogData data : list) {
            Map<Integer, DbParameter> para = new HashMap<>();
            int i = 1;
            para.put(i++, new DbParameter(Types.BIGINT, data.getGroupId()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getWeekId()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getFortressId()));
            para.put(i++, new DbParameter(Types.VARCHAR, data.getUnionId()));
            para.put(i++, new DbParameter(Types.BIGINT, data.getUnionDispatchEarn()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getRank()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getLogTime()));
            mapList.add(para);
        }
        if (getDb().executeBatchQuery(sql, mapList) > -1) {
            result = true;
        }
        return result;
    }

    public boolean addMonopolyMarketOfficeUserSeatLogDataList(List<MonopolyMarketOfficeUserSeatLogData> list) {
        boolean result = false;
        getDb().setConnName(DbNameStrategy.getLogDb());
        String sql = "INSERT INTO t_l_monopolymarket_office_user_seat_log_data(userId,posIndex,level,no,type,num,lastSeatTime,logTime) VALUES(?,?,?,?,?,?,?,?)";
        List<Map<Integer, DbParameter>> mapList = new ArrayList<>();
        for (MonopolyMarketOfficeUserSeatLogData data : list) {
            Map<Integer, DbParameter> para = new HashMap<>();
            int i = 1;
            para.put(i++, new DbParameter(Types.BIGINT, data.getUserId()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getPosIndex()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getLevel()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getNo()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getType()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getNum()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getLastSeatTime()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getLogTime()));
            mapList.add(para);
        }
        if (getDb().executeBatchQuery(sql, mapList) > -1) {
            result = true;
        }
        return result;
    }

}
